package folder.main.exp4;

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.math3.distribution.TDistribution;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;

import folder.model.network.Network;
import folder.model.network.NetworkRandom;
import folder.model.node.Node;
import folder.model.virtual.VirtualNetwork;
import folder.model.virtual.VirtualNetworkRandom;

public class Exp4
{
	// Figure 1: Number virtual networks / Network degree
	
	static String File11MeanDelayEmpty     = "C:/Users/aurelioj/Google Drive/R/Exp4/File11MeanDelayEmpty.txt";
	static String File12LongestDelayEmpty  = "C:/Users/aurelioj/Google Drive/R/Exp4/File12LongestDelayEmpty.txt";
	static String File13DelayEmpty         = "C:/Users/aurelioj/Google Drive/R/Exp4/File13DelayEmpty.txt";
	
	static String File21MeanDelayFull    = "C:/Users/aurelioj/Google Drive/R/Exp4/File21MeanDelayFull.txt";
	static String File22LongestDelayFull = "C:/Users/aurelioj/Google Drive/R/Exp4/File22LongestDelayFull.txt";
	static String File23DelayFull        = "C:/Users/aurelioj/Google Drive/R/Exp4/File23DelayFull.txt";
	
	static String File31MeanDelayRelation    = "C:/Users/aurelioj/Google Drive/R/Exp4/File31MeanDelayRelation.txt";
	static String File32LongestDelayRelation = "C:/Users/aurelioj/Google Drive/R/Exp4/File32LongestDelayRelation.txt";
	static String File33DelayRelation        = "C:/Users/aurelioj/Google Drive/R/Exp4/File33DelayRelation.txt";
	
	static String File40PercentageOccupation = "C:/Users/aurelioj/Google Drive/R/Exp4/File40PercentageOccupation.txt";
	
	static int NUMBER_EVALUATIONS = 1000;
	
	static int NUMBER_LINKS = 100;	// Min 30
	
	static int NUMBER_VIRTUAL_NETWORKS_20 = 920;
	static int NUMBER_VIRTUAL_NETWORKS_19 = 980;
	static int NUMBER_VIRTUAL_NETWORKS_18 = 1040;
	static int NUMBER_VIRTUAL_NETWORKS_17 = 1110;
	static int NUMBER_VIRTUAL_NETWORKS_16 = 1180;
	static int NUMBER_VIRTUAL_NETWORKS_15 = 1270;
	
	static Network network20;
	static Network network19;
	static Network network18;
	static Network network17;
	static Network network16;
	static Network network15;
	
	static List< VirtualNetwork > virtualNetworks20 = setVirtualNetworks( NUMBER_VIRTUAL_NETWORKS_20 );
	static List< VirtualNetwork > virtualNetworks19 = setVirtualNetworks( NUMBER_VIRTUAL_NETWORKS_19 );
	static List< VirtualNetwork > virtualNetworks18 = setVirtualNetworks( NUMBER_VIRTUAL_NETWORKS_18 );
	static List< VirtualNetwork > virtualNetworks17 = setVirtualNetworks( NUMBER_VIRTUAL_NETWORKS_17 );
	static List< VirtualNetwork > virtualNetworks16 = setVirtualNetworks( NUMBER_VIRTUAL_NETWORKS_16 );
	static List< VirtualNetwork > virtualNetworks15 = setVirtualNetworks( NUMBER_VIRTUAL_NETWORKS_15 );
	
	static SummaryStatistics sumMeanDelayEmpty20 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayEmpty19 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayEmpty18 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayEmpty17 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayEmpty16 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayEmpty15 = new SummaryStatistics();

	static SummaryStatistics sumLongestDelayEmpty20 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayEmpty19 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayEmpty18 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayEmpty17 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayEmpty16 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayEmpty15 = new SummaryStatistics();
	
	static SummaryStatistics sumMeanDelayFull20 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayFull19 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayFull18 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayFull17 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayFull16 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayFull15 = new SummaryStatistics();
	
	static SummaryStatistics sumLongestDelayFull20 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayFull19 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayFull18 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayFull17 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayFull16 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayFull15 = new SummaryStatistics();
	
	static SummaryStatistics sumMeanDelayRelation20 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayRelation19 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayRelation18 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayRelation17 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayRelation16 = new SummaryStatistics();
	static SummaryStatistics sumMeanDelayRelation15 = new SummaryStatistics();
	
	static SummaryStatistics sumLongestDelayRelation20 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayRelation19 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayRelation18 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayRelation17 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayRelation16 = new SummaryStatistics();
	static SummaryStatistics sumLongestDelayRelation15 = new SummaryStatistics();
	
	static SummaryStatistics sumPercentageOccupation20 = new SummaryStatistics();
	static SummaryStatistics sumPercentageOccupation19 = new SummaryStatistics();
	static SummaryStatistics sumPercentageOccupation18 = new SummaryStatistics();
	static SummaryStatistics sumPercentageOccupation17 = new SummaryStatistics();
	static SummaryStatistics sumPercentageOccupation16 = new SummaryStatistics();
	static SummaryStatistics sumPercentageOccupation15 = new SummaryStatistics();
	
	static int identifierEvaluation = 0;
	
	public static void main( String[] args )
	{
		while( identifierEvaluation < NUMBER_EVALUATIONS )
		{
			setNetworks();
			
			setPathNetworks();
			
			double meanDelayEmptyMax20 = getMeanDelayMax( network20 );
			double meanDelayEmptyMax19 = getMeanDelayMax( network19 );
			double meanDelayEmptyMax18 = getMeanDelayMax( network18 );
			double meanDelayEmptyMax17 = getMeanDelayMax( network17 );
			double meanDelayEmptyMax16 = getMeanDelayMax( network16 );
			double meanDelayEmptyMax15 = getMeanDelayMax( network15 );
			
			double longestDelayEmptyMax20 = getLongestDelayMax( network20 );
			double longestDelayEmptyMax19 = getLongestDelayMax( network19 );
			double longestDelayEmptyMax18 = getLongestDelayMax( network18 );
			double longestDelayEmptyMax17 = getLongestDelayMax( network17 );
			double longestDelayEmptyMax16 = getLongestDelayMax( network16 );
			double longestDelayEmptyMax15 = getLongestDelayMax( network15 );
			
			allocateVirtualNetworks();
			setPathNetworks();
			
			double meanDelayFullMax20 = getMeanDelayMax( network20 );
			double meanDelayFullMax19 = getMeanDelayMax( network19 );
			double meanDelayFullMax18 = getMeanDelayMax( network18 );
			double meanDelayFullMax17 = getMeanDelayMax( network17 );
			double meanDelayFullMax16 = getMeanDelayMax( network16 );
			double meanDelayFullMax15 = getMeanDelayMax( network15 );
			
			double longestDelayFullMax20 = getLongestDelayMax( network20 );
			double longestDelayFullMax19 = getLongestDelayMax( network19 );
			double longestDelayFullMax18 = getLongestDelayMax( network18 );
			double longestDelayFullMax17 = getLongestDelayMax( network17 );
			double longestDelayFullMax16 = getLongestDelayMax( network16 );
			double longestDelayFullMax15 = getLongestDelayMax( network15 );
			
			if(    meanDelayFullMax20 < Double.POSITIVE_INFINITY && 
				   meanDelayFullMax19 < Double.POSITIVE_INFINITY && 
				   meanDelayFullMax18 < Double.POSITIVE_INFINITY &&
				   meanDelayFullMax17 < Double.POSITIVE_INFINITY &&
				   meanDelayFullMax16 < Double.POSITIVE_INFINITY &&
				   meanDelayFullMax15 < Double.POSITIVE_INFINITY &&
				longestDelayFullMax20 < Double.POSITIVE_INFINITY && 
				longestDelayFullMax19 < Double.POSITIVE_INFINITY && 
				longestDelayFullMax18 < Double.POSITIVE_INFINITY &&
				longestDelayFullMax17 < Double.POSITIVE_INFINITY &&
				longestDelayFullMax16 < Double.POSITIVE_INFINITY &&
				longestDelayFullMax15 < Double.POSITIVE_INFINITY )
			{
				sumMeanDelayEmpty20.addValue( meanDelayEmptyMax20 );
				sumMeanDelayEmpty19.addValue( meanDelayEmptyMax19 );
				sumMeanDelayEmpty18.addValue( meanDelayEmptyMax18 );
				sumMeanDelayEmpty17.addValue( meanDelayEmptyMax17 );
				sumMeanDelayEmpty16.addValue( meanDelayEmptyMax16 );
				sumMeanDelayEmpty15.addValue( meanDelayEmptyMax15 );
				
				sumLongestDelayEmpty20.addValue( longestDelayEmptyMax20 );
				sumLongestDelayEmpty19.addValue( longestDelayEmptyMax19 );
				sumLongestDelayEmpty18.addValue( longestDelayEmptyMax18 );
				sumLongestDelayEmpty17.addValue( longestDelayEmptyMax17 );
				sumLongestDelayEmpty16.addValue( longestDelayEmptyMax16 );
				sumLongestDelayEmpty15.addValue( longestDelayEmptyMax15 );
				
				sumMeanDelayFull20.addValue( meanDelayFullMax20 );
				sumMeanDelayFull19.addValue( meanDelayFullMax19 );
				sumMeanDelayFull18.addValue( meanDelayFullMax18 );
				sumMeanDelayFull17.addValue( meanDelayFullMax17 );
				sumMeanDelayFull16.addValue( meanDelayFullMax16 );
				sumMeanDelayFull15.addValue( meanDelayFullMax15 );
				
				sumLongestDelayFull20.addValue( longestDelayFullMax20 );
				sumLongestDelayFull19.addValue( longestDelayFullMax19 );
				sumLongestDelayFull18.addValue( longestDelayFullMax18 );
				sumLongestDelayFull17.addValue( longestDelayFullMax17 );
				sumLongestDelayFull16.addValue( longestDelayFullMax16 );
				sumLongestDelayFull15.addValue( longestDelayFullMax15 );
				
				sumMeanDelayRelation20.addValue( meanDelayFullMax20 / meanDelayEmptyMax20 );
				sumMeanDelayRelation19.addValue( meanDelayFullMax19 / meanDelayEmptyMax19 );
				sumMeanDelayRelation18.addValue( meanDelayFullMax18 / meanDelayEmptyMax18 );
				sumMeanDelayRelation17.addValue( meanDelayFullMax17 / meanDelayEmptyMax17 );
				sumMeanDelayRelation16.addValue( meanDelayFullMax16 / meanDelayEmptyMax16 );
				sumMeanDelayRelation15.addValue( meanDelayFullMax15 / meanDelayEmptyMax15 );
								
				sumLongestDelayRelation20.addValue( longestDelayFullMax20 / longestDelayEmptyMax20 );
				sumLongestDelayRelation19.addValue( longestDelayFullMax19 / longestDelayEmptyMax19 );
				sumLongestDelayRelation18.addValue( longestDelayFullMax18 / longestDelayEmptyMax18 );
				sumLongestDelayRelation17.addValue( longestDelayFullMax17 / longestDelayEmptyMax17 );
				sumLongestDelayRelation16.addValue( longestDelayFullMax16 / longestDelayEmptyMax16 );
				sumLongestDelayRelation15.addValue( longestDelayFullMax15 / longestDelayEmptyMax15 );
				
				sumPercentageOccupation20.addValue( getPercentageOccupation( network20 ) );
				sumPercentageOccupation19.addValue( getPercentageOccupation( network19 ) );
				sumPercentageOccupation18.addValue( getPercentageOccupation( network18 ) );
				sumPercentageOccupation17.addValue( getPercentageOccupation( network17 ) );
				sumPercentageOccupation16.addValue( getPercentageOccupation( network16 ) );
				sumPercentageOccupation15.addValue( getPercentageOccupation( network15 ) );
				
				identifierEvaluation++;
				System.out.println( identifierEvaluation );
			}
			
			releaseVirtualNetworks();
		}
		
		System.out.println( "Number of evaluations: " + NUMBER_EVALUATIONS );
		
		printAndSave();
	}
	
	static void setNetworks()
	{
		network20 = NetworkRandom.networkRandom( 20, NUMBER_LINKS );
		network19 = NetworkRandom.networkRandom( 19, NUMBER_LINKS );
		network18 = NetworkRandom.networkRandom( 18, NUMBER_LINKS );
		network17 = NetworkRandom.networkRandom( 17, NUMBER_LINKS );
		network16 = NetworkRandom.networkRandom( 16, NUMBER_LINKS );
		network15 = NetworkRandom.networkRandom( 15, NUMBER_LINKS );
	}
	
	static void setPathNetworks()
	{
		network20.setPathsNetwork();
		network19.setPathsNetwork();
		network18.setPathsNetwork();
		network17.setPathsNetwork();
		network16.setPathsNetwork();
		network15.setPathsNetwork();
	}
	
	static List< VirtualNetwork > setVirtualNetworks( int numberVirtualNetworks )
	{
		List< VirtualNetwork > virtualNetworks = new ArrayList< VirtualNetwork >();
		
		for( int i = 0; i < numberVirtualNetworks; i++ )
		{
			VirtualNetwork virtualNetworkRandom = VirtualNetworkRandom.virtualNetworkRandom( i );
			virtualNetworks.add( virtualNetworkRandom );
		}
		
		return virtualNetworks;
	}
	
	static double getMeanDelayMax( Network network )
	{		
		SummaryStatistics sum = new SummaryStatistics();
		
		for( Node node: network.getNodes() )
			sum.addValue( node.getDelayToNodeTargetMean() );
		
		return sum.getMean();
	}
	
	static double getLongestDelayMax( Network network )
	{		
		SummaryStatistics sum = new SummaryStatistics();
		
		for( Node node: network.getNodes() )
			sum.addValue( node.getDelayToNodeTargetLongest() );
		
		return sum.getMax();
	}
	
	static void printAndSave()
	{
		DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
		decimalFormatSymbols.setDecimalSeparator( '.' );
		DecimalFormat decimalFormat = new DecimalFormat( "0.00", decimalFormatSymbols );
		double factor = 1000000;
		
		String strMeanDelayEmpty20 = getStringOfData( sumMeanDelayEmpty20, decimalFormat, factor );
		String strMeanDelayEmpty19 = getStringOfData( sumMeanDelayEmpty19, decimalFormat, factor );
		String strMeanDelayEmpty18 = getStringOfData( sumMeanDelayEmpty18, decimalFormat, factor );
		String strMeanDelayEmpty17 = getStringOfData( sumMeanDelayEmpty17, decimalFormat, factor );
		String strMeanDelayEmpty16 = getStringOfData( sumMeanDelayEmpty16, decimalFormat, factor );
		String strMeanDelayEmpty15 = getStringOfData( sumMeanDelayEmpty15, decimalFormat, factor );
		
		String strLongestDelayEmpty20 = getStringOfData( sumLongestDelayEmpty20, decimalFormat, factor );
		String strLongestDelayEmpty19 = getStringOfData( sumLongestDelayEmpty19, decimalFormat, factor );
		String strLongestDelayEmpty18 = getStringOfData( sumLongestDelayEmpty18, decimalFormat, factor );
		String strLongestDelayEmpty17 = getStringOfData( sumLongestDelayEmpty17, decimalFormat, factor );
		String strLongestDelayEmpty16 = getStringOfData( sumLongestDelayEmpty16, decimalFormat, factor );
		String strLongestDelayEmpty15 = getStringOfData( sumLongestDelayEmpty15, decimalFormat, factor );
		
		String strMeanDelayFull20 = getStringOfData( sumMeanDelayFull20, decimalFormat, factor );
		String strMeanDelayFull19 = getStringOfData( sumMeanDelayFull19, decimalFormat, factor );
		String strMeanDelayFull18 = getStringOfData( sumMeanDelayFull18, decimalFormat, factor );
		String strMeanDelayFull17 = getStringOfData( sumMeanDelayFull17, decimalFormat, factor );
		String strMeanDelayFull16 = getStringOfData( sumMeanDelayFull16, decimalFormat, factor );
		String strMeanDelayFull15 = getStringOfData( sumMeanDelayFull15, decimalFormat, factor );
		
		String strLongestDelayFull20 = getStringOfData( sumLongestDelayFull20, decimalFormat, factor );
		String strLongestDelayFull19 = getStringOfData( sumLongestDelayFull19, decimalFormat, factor );
		String strLongestDelayFull18 = getStringOfData( sumLongestDelayFull18, decimalFormat, factor );
		String strLongestDelayFull17 = getStringOfData( sumLongestDelayFull17, decimalFormat, factor );
		String strLongestDelayFull16 = getStringOfData( sumLongestDelayFull16, decimalFormat, factor );
		String strLongestDelayFull15 = getStringOfData( sumLongestDelayFull15, decimalFormat, factor );
		
		String strMeanDelayRelation20 = getStringOfData( sumMeanDelayRelation20, decimalFormat, 1 );
		String strMeanDelayRelation19 = getStringOfData( sumMeanDelayRelation19, decimalFormat, 1 );
		String strMeanDelayRelation18 = getStringOfData( sumMeanDelayRelation18, decimalFormat, 1 );
		String strMeanDelayRelation17 = getStringOfData( sumMeanDelayRelation17, decimalFormat, 1 );
		String strMeanDelayRelation16 = getStringOfData( sumMeanDelayRelation16, decimalFormat, 1 );
		String strMeanDelayRelation15 = getStringOfData( sumMeanDelayRelation15, decimalFormat, 1 );
		
		String strLongestDelayRelation20 = getStringOfData( sumLongestDelayRelation20, decimalFormat, 1 );
		String strLongestDelayRelation19 = getStringOfData( sumLongestDelayRelation19, decimalFormat, 1 );
		String strLongestDelayRelation18 = getStringOfData( sumLongestDelayRelation18, decimalFormat, 1 );
		String strLongestDelayRelation17 = getStringOfData( sumLongestDelayRelation17, decimalFormat, 1 );
		String strLongestDelayRelation16 = getStringOfData( sumLongestDelayRelation16, decimalFormat, 1 );
		String strLongestDelayRelation15 = getStringOfData( sumLongestDelayRelation15, decimalFormat, 1 );
		
		String strPercentageOccupation20 = getStringOfData( sumPercentageOccupation20, decimalFormat, 100 );
		String strPercentageOccupation19 = getStringOfData( sumPercentageOccupation19, decimalFormat, 100 );
		String strPercentageOccupation18 = getStringOfData( sumPercentageOccupation18, decimalFormat, 100 );
		String strPercentageOccupation17 = getStringOfData( sumPercentageOccupation17, decimalFormat, 100 );
		String strPercentageOccupation16 = getStringOfData( sumPercentageOccupation16, decimalFormat, 100 );
		String strPercentageOccupation15 = getStringOfData( sumPercentageOccupation15, decimalFormat, 100 );
		
		String strMeanDelayEmpty = strMeanDelayEmpty20 + strMeanDelayEmpty19 + strMeanDelayEmpty18 + strMeanDelayEmpty17 + strMeanDelayEmpty16 + strMeanDelayEmpty15;
		String strLongestDelayEmpty = strLongestDelayEmpty20 + strLongestDelayEmpty19 + strLongestDelayEmpty18 + strLongestDelayEmpty17 + strLongestDelayEmpty16 + strLongestDelayEmpty15;
		String strDelayEmpty = strMeanDelayEmpty + strLongestDelayEmpty;
		
		String strMeanDelayFull = strMeanDelayFull20 + strMeanDelayFull19 + strMeanDelayFull18 + strMeanDelayFull17 + strMeanDelayFull16 + strMeanDelayFull15;
		String strLongestDelayFull = strLongestDelayFull20 + strLongestDelayFull19 + strLongestDelayFull18 + strLongestDelayFull17 + strLongestDelayFull16 + strLongestDelayFull15;
		String strDelayFull = strMeanDelayFull + strLongestDelayFull;
		
		String strMeanDelayRelation = strMeanDelayRelation20 + strMeanDelayRelation19 + strMeanDelayRelation18 + strMeanDelayRelation17 + strMeanDelayRelation16 + strMeanDelayRelation15;
		String strLongestDelayRelation = strLongestDelayRelation20 + strLongestDelayRelation19 + strLongestDelayRelation18 + strLongestDelayRelation17 + strLongestDelayRelation16 + strLongestDelayRelation15;
		String strDelayRelation = strMeanDelayRelation + strLongestDelayRelation;
		
		String strPercentageOccupation = strPercentageOccupation20 + strPercentageOccupation19 + strPercentageOccupation18 + strPercentageOccupation17 + strPercentageOccupation16 + strPercentageOccupation15;
		
		addDataToFile( strMeanDelayEmpty, File11MeanDelayEmpty );
		addDataToFile( strLongestDelayEmpty, File12LongestDelayEmpty );
		addDataToFile( strDelayEmpty, File13DelayEmpty );
		
		addDataToFile( strMeanDelayFull, File21MeanDelayFull );
		addDataToFile( strLongestDelayFull, File22LongestDelayFull );
		addDataToFile( strDelayFull, File23DelayFull );
		
		addDataToFile( strMeanDelayRelation, File31MeanDelayRelation );
		addDataToFile( strLongestDelayRelation, File32LongestDelayRelation );
		addDataToFile( strDelayRelation, File33DelayRelation );
				
		addDataToFile( strPercentageOccupation, File40PercentageOccupation );
		
		System.out.println();
		System.out.println( "MeanDelayEmpty20:\t" + strMeanDelayEmpty20 );
		System.out.println( "MeanDelayEmpty19:\t" + strMeanDelayEmpty19 );
		System.out.println( "MeanDelayEmpty18:\t" + strMeanDelayEmpty18 );
		System.out.println( "MeanDelayEmpty17:\t" + strMeanDelayEmpty17 );
		System.out.println( "MeanDelayEmpty16:\t" + strMeanDelayEmpty16 );
		System.out.println( "MeanDelayEmpty15:\t" + strMeanDelayEmpty15 );
		System.out.println();
		System.out.println( "LongestDelayEmpty20:\t" + strLongestDelayEmpty20 );
		System.out.println( "LongestDelayEmpty19:\t" + strLongestDelayEmpty19 );
		System.out.println( "LongestDelayEmpty18:\t" + strLongestDelayEmpty18 );
		System.out.println( "LongestDelayEmpty17:\t" + strLongestDelayEmpty17 );
		System.out.println( "LongestDelayEmpty16:\t" + strLongestDelayEmpty16 );
		System.out.println( "LongestDelayEmpty15:\t" + strLongestDelayEmpty15 );
		System.out.println();
		System.out.println( "MeanDelayFull20:\t" + strMeanDelayFull20 );
		System.out.println( "MeanDelayFull19:\t" + strMeanDelayFull19 );
		System.out.println( "MeanDelayFull18:\t" + strMeanDelayFull18 );
		System.out.println( "MeanDelayFull17:\t" + strMeanDelayFull17 );
		System.out.println( "MeanDelayFull16:\t" + strMeanDelayFull16 );
		System.out.println( "MeanDelayFull15:\t" + strMeanDelayFull15 );
		System.out.println();
		System.out.println( "LongestDelayFull20:\t" + strLongestDelayFull20 );
		System.out.println( "LongestDelayFull19:\t" + strLongestDelayFull19 );
		System.out.println( "LongestDelayFull18:\t" + strLongestDelayFull18 );
		System.out.println( "LongestDelayFull17:\t" + strLongestDelayFull17 );
		System.out.println( "LongestDelayFull16:\t" + strLongestDelayFull16 );
		System.out.println( "LongestDelayFull15:\t" + strLongestDelayFull15 );
		System.out.println();
		System.out.println( "MeanDelayRelation20:\t" + strMeanDelayRelation20 );
		System.out.println( "MeanDelayRelation19:\t" + strMeanDelayRelation19 );
		System.out.println( "MeanDelayRelation18:\t" + strMeanDelayRelation18 );
		System.out.println( "MeanDelayRelation17:\t" + strMeanDelayRelation17 );
		System.out.println( "MeanDelayRelation16:\t" + strMeanDelayRelation16 );
		System.out.println( "MeanDelayRelation15:\t" + strMeanDelayRelation15 );
		System.out.println();
		System.out.println( "LongestDelayRelation20:\t" + strLongestDelayRelation20 );
		System.out.println( "LongestDelayRelation19:\t" + strLongestDelayRelation19 );
		System.out.println( "LongestDelayRelation18:\t" + strLongestDelayRelation18 );
		System.out.println( "LongestDelayRelation17:\t" + strLongestDelayRelation17 );
		System.out.println( "LongestDelayRelation16:\t" + strLongestDelayRelation16 );
		System.out.println( "LongestDelayRelation15:\t" + strLongestDelayRelation15 );
		System.out.println();
		System.out.println( "PercentageOccupation20:\t" + strPercentageOccupation20 );
		System.out.println( "PercentageOccupation19:\t" + strPercentageOccupation19 );
		System.out.println( "PercentageOccupation18:\t" + strPercentageOccupation18 );
		System.out.println( "PercentageOccupation17:\t" + strPercentageOccupation17 );
		System.out.println( "PercentageOccupation16:\t" + strPercentageOccupation16 );
		System.out.println( "PercentageOccupation15:\t" + strPercentageOccupation15 );
	}
	
	static void allocateVirtualNetworks()
	{
		allocateVirtualNetworks( network20, virtualNetworks20 );
		allocateVirtualNetworks( network19, virtualNetworks19 );
		allocateVirtualNetworks( network18, virtualNetworks18 );
		allocateVirtualNetworks( network17, virtualNetworks17 );
		allocateVirtualNetworks( network16, virtualNetworks16 );
		allocateVirtualNetworks( network15, virtualNetworks15 );
	}
	
	static void releaseVirtualNetworks()
	{
		releaseVirtualNetworks( network20, virtualNetworks20 );
		releaseVirtualNetworks( network19, virtualNetworks19 );
		releaseVirtualNetworks( network18, virtualNetworks18 );
		releaseVirtualNetworks( network17, virtualNetworks17 );
		releaseVirtualNetworks( network16, virtualNetworks16 );
		releaseVirtualNetworks( network15, virtualNetworks15 );
	}
	
	static void releaseVirtualNetworks( Network network, List< VirtualNetwork > virtualNetworks )
	{
		for( VirtualNetwork virtualNetwork: virtualNetworks )
			network.release( virtualNetwork );
	}
	
	static boolean allocateVirtualNetworks( Network network, List< VirtualNetwork > virtualNetworks )
	{
		for( VirtualNetwork virtualNetwork: virtualNetworks )
			if( !network.allocate( virtualNetwork ) )
				return false;
		
		return true;
	}
	
	static double getPercentageOccupation( Network network )
	{
		double percentageOccupation = 0;
		
		for( Node node: network.getNodes() )
		{
			node.setBandwidthOccupation();
			
			if( node.getBandwidthOccupation() > percentageOccupation )
				percentageOccupation = node.getBandwidthOccupation();
		}
		
		return percentageOccupation;
	}
	
	static void addDataToFile( String data, String fileName )
	{
		try {
			FileWriter fileWriter = new FileWriter( fileName, true );
			PrintWriter printWriter = new PrintWriter( fileWriter );
			printWriter.println( data );
			printWriter.close();
			
		} catch (IOException e) {e.printStackTrace();}
	}
	
	static String getStringOfData( SummaryStatistics sum, DecimalFormat decimalFormat, double factor )
	{
		double mean = sum.getMean();
		double width = getConfidenceIntervalWidth( sum, 0.05 );
		return ( decimalFormat.format( mean * factor ) ) + "\t" + decimalFormat.format( ( mean - width ) * factor ) + "\t" + decimalFormat.format( ( mean + width ) * factor ) + "\t";
	}
	
	static double getConfidenceIntervalWidth( SummaryStatistics sum, double significance ) //throws MathException
	{
		if( sum.getN() == 0 )
			return 0;
		
		long N = sum.getN() > 1 ? sum.getN() : 2;
				
		TDistribution tDist = new TDistribution( N - 1 );
		double a = tDist.inverseCumulativeProbability( 1.0 - significance / 2 );
		return a * sum.getStandardDeviation() / Math.sqrt( sum.getN() );
	}
	
}
